﻿using TheMethod;
namespace homework6_LeastSquareMethod
{
    internal class Program
    {
        /// <summary>
        /// 预测2021年的GDP
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //数组内包含2001年到2020年的GDP数据
            double[]gdp = new double[20] 
            {
                1339395718862,1470550015077,1660287965663,1955347004965,2285965892364,2752131773358,3550342737358,4594307032667,5101703073088,6087163874510,
                7551500124197,8532229986993,9570406235659,10475682920597,11061553079871,11233276536744,12310409370894,13894817549380,14279937500608,14687673892882
            };
            //2001年到2020年
            double[] year = new double[20]
            {
                2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,
                2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
            };
            Console.WriteLine("请输入年份");
            string input = Console.ReadLine();
            int theYear = int.Parse(input);
            double theGDP = 0;
            Console.WriteLine($"预测{theYear}年的GDP值为{LinearRegression.LinearRegressionModel(gdp,year,theYear,theGDP)}");
            double deviation = LinearRegression.LinearRegressionModel(gdp, year, theYear, theGDP) - 17734062645371;
            Console.WriteLine($"偏差为{deviation / 17734062645371 * 100}%");
        }
    }
}